<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script> 
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	
		<!-- DWR -->
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	   	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>
<script type="text/javascript">

//根据条件查询资产信息
function queryAssetCard(){
	   var property=document.getElementById("condition");
	   var condition=property.options[property.selectedIndex].value;
		if(condition=="zczt"){
			var propertyBeChoose=document.getElementById("acstatusValue");
			var acstatusValue=propertyBeChoose.options[propertyBeChoose.selectedIndex].value;
			location.href = "searchExternalByCondition.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&acstatusValue="+encodeURIComponent($('#acstatusValue').val());   
		}else{
			var conditionValue=document.getElementById("conditionValue").value;
 	        location.href="searchExternalByCondition.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&conditionValue="+encodeURIComponent($('#conditionValue').val());   
		}
		 }
//将数据导出
  function exportTable(){ 
	   if(confirm("确定要导出所有记录吗?")){
         window.location.href="outputExternalAssetCard.action?FN=<s:property value='FN'/>";
	   } 
  }
//原部门经办已申请
function oldJbAsk(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
       }
    }
    //如果没有被选中，那么不进行任何操作
    if(j==0){
  	   alert('请选择要进行申请的资产.');
         return;
         }
    var newArray = new Array(j);
    for(var i=0;i<j;i++){
        newArray[i]=array[i];
    }
    if(confirm("确定已经申请资产.")){
        document.getElementById("hiddengoodsacid").value = newArray; 
        document.getElementById("hiddengoodsform").submit();
     }
	 }
//刷新页面
 function refresh(){
	    window.location.href="page/basic/searchExternal.action?FN=<s:property value='FN' />";
	  }
//原部门经办上报资产
function oldJbReport(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
       }
    }
    //如果没有被选中，那么不进行任何操作
    if(j==0){
  	   alert('请选择待要上报的资产.');
         return;
         }
    var newArray = new Array(j);
    for(var i=0;i<j;i++){
        newArray[i]=array[i];
    }
    if(confirm("确定物资上报.")){
               document.getElementById("hiddenallotacid").value = newArray; 
               document.getElementById("hiddenallotform").submit();
     }
	 }
//原部门领导已审核     只能审核一条资产
function oldLdAudit(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
       }
    }
    //如果没有被选中，那么不进行任何操作
    if(j==0){
  	   alert('请选择要进行分配的资产.');
         return;
         }
    var newArray = new Array(j);
    for(var i=0;i<j;i++){
        newArray[i]=array[i];
    }
    if(j > 1){
			alert('请选择某一条具体的资产再进行此操作.');
			return false;
		}
	  var res = window.showModalDialog("/SSS/page/basic/result.jsp?param=0",null,"dialogWidth=520px;dialogHeight=450px;status=0;scroll=0");
	  document.getElementById("hiddenfpacid").value = newArray;
	  document.getElementById("oldLdAuditResult").value = res;
     document.getElementById("hiddenfpform").submit();
	 }
//原部门领导退回资产  一条一条的退回
function oldLdBack(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
       }
    }
    //如果没有被选中，那么不进行任何操作
    if(j==0){
  	   alert('请选择要进行退回的资产.');
         return;
         }
    var newArray = new Array(j);
    for(var i=0;i<j;i++){
        newArray[i]=array[i];
    }
    if(j > 1){
			alert('请选择某一条具体的资产再进行此操作.');
			return false;
		}
	  var res = window.showModalDialog("/SSS/page/basic/result.jsp?param=1",null,"dialogWidth=520px;dialogHeight=450px;status=0;scroll=0");
	  document.getElementById("hiddenbackacid").value = newArray;
	  document.getElementById("oldLdBackResult").value = res;
     document.getElementById("hiddenbackform").submit();
	 }


//原部门领导已转交
function oldLdPass(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
       }
    }
    //如果没有被选中，那么不进行任何操作
    if(j==0){
  	   alert('请选择要进行转交的资产.');
         return;
         }
    var newArray = new Array(j);
    for(var i=0;i<j;i++){
        newArray[i]=array[i];
    }
    if(j > 1){
			alert('请选择某一条具体的资产再进行此操作.');
			return false;
		}
   var depValue = window.showModalDialog("/SSS/page/basic/depTree.jsp",null,"dialogWidth=320px;dialogHeight=450px;status=0;scroll=0");
	if(depValue == undefined){
  	  	depValue = '';
  	}
	var depid = (depValue=='')?'':depValue.split(',')[0];
	var depname = (depValue=='')?'':depValue.split(',')[1];
	if(depid != undefined && depname != undefined){
		document.getElementById("depid").value = depid;
		document.getElementById("depname").value = depname;
		if(depname.trim()==document.getElementById("selectdepname").value.trim()){
	 		 alert("不能本部门之间进行调动,请重新选择");
	 		}
		else{
	 		  if(confirm("确认转交给"+depname)){
	              document.getElementById("hiddenpassacid").value = newArray;
                 document.getElementById("hiddenpassform").submit();}
 	 		}
      }	
	 }
//新部门领导审核资产
function newLDAudit(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
       }
    }
    //如果没有被选中，那么不进行任何操作
    if(j==0){
  	   alert('请选择要进行审核的资产.');
         return;
         }
    var newArray = new Array(j);
    for(var i=0;i<j;i++){
        newArray[i]=array[i];
    }
    if(j > 1){
			alert('请选择某一条具体的资产再进行此操作.');
			return false;
		}
	  var res = window.showModalDialog("/SSS/page/basic/result.jsp?param=0",null,"dialogWidth=520px;dialogHeight=450px;status=0;scroll=0");
	  document.getElementById("hiddenauditacid").value = newArray;
	  document.getElementById("newLDAuditResult").value = res;
     document.getElementById("hiddenauditform").submit();
	 }
//新部门领导退回资产  一条一条的退回
function newLDBack(){
	 var allId = document.getElementsByName("checkbox");
    var array = new Array(allId.length);
    var j=0;
    for(var i=0;i<allId.length;i++){
       if(allId[i].checked==true){
            array[j] = allId[i].value;
            j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行退回的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(j > 1){
			alert('请选择某一条具体的资产再进行此操作.');
			return false;
		}
	  var res = window.showModalDialog("page/basic/result.jsp?param=1",null,"dialogWidth=520px;dialogHeight=450px;status=0;scroll=0");
	  document.getElementById("hiddennewbackacid").value = newArray;
	  document.getElementById("newLDBackResult").value = res;
      document.getElementById("hiddennewbackform").submit();
	 }
//新部门领导进行下传
 function newLDDownload(){
	 var allId = document.getElementsByName("checkbox");
     var array = new Array(allId.length);
     var j=0;
     for(var i=0;i<allId.length;i++){
        if(allId[i].checked==true){
             array[j] = allId[i].value;
             j++;
        }
     }
     //如果没有被选中，那么不进行任何操作
     if(j==0){
   	   alert('请选择要进行下传的资产.');
          return;
          }
     var newArray = new Array(j);
     for(var i=0;i<j;i++){
         newArray[i]=array[i];
     }
     if(j > 1){
			alert('请选择某一条具体的资产再进行此操作.');
			return false;
		}
	  document.getElementById("hiddennewloadacid").value = newArray;
      document.getElementById("hiddennewloadform").submit();
	 }
 //外调--新部门经办进行资产分配
    function newJBallot(){
    	 var allId = document.getElementsByName("checkbox");
         var array = new Array(allId.length);
         var j=0;
         for(var i=0;i<allId.length;i++){
            if(allId[i].checked==true){
                 array[j] = allId[i].value;
                 j++;
            }
         }
         //如果没有被选中，那么不进行任何操作
         if(j==0){
       	   alert('请选择要进行分配的资产.');
              return;
              }
         var newArray = new Array(j);
         for(var i=0;i<j;i++){
             newArray[i]=array[i];
         }
         if(j > 1){
    			alert('请选择某一条具体的资产再进行此操作.');
    			return false;
    		}
 		 var name = window.showModalDialog("getStaffs.action",null,"dialogWidth=520px;dialogHeight=450px;status=0;scroll=0");
      if("确定将资产分配给"+name){
    	  document.getElementById("hiddennewfpacid").value = newArray;
    	  document.getElementById("user").value = name;
          document.getElementById("hiddennewfpform").submit();
          }
        }
//条件选择
	function chose(){
		var property=document.getElementById("condition");
		var conditionValue=document.getElementById("conditionValue");
		var acstatusValue=document.getElementById("acstatusValue");
		if(property.options[property.selectedIndex].value=="zczt"){
			conditionValue.style.display="none";	
			acstatusValue.style.display="inline";
		}else{
			conditionValue.style.display="inline";	
			acstatusValue.style.display="none";
		}
	}

//得到选中的所在部门
	function check(selectedTr){ 
      if(selectedTr!=null){   
        var str=selectedTr.cells[3].innerText; 
        document.getElementById("selectdepname").innerText=str;
       } 
	}
</script>	   	

  </head>
  
  <body>
  <div class="mainContainer">
    <div class="headerTitle">日常信息管理&nbsp;>>&nbsp;资产外部调动管理</div>
    
       <div class="dtreeDiv" id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0, -1, '广元电业局',"searchExternal.action?FN=<s:property value='FN' />");
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var url = "queryExternalAssetCardByCategory.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
			</script>
		</div>
		
     	<div class="dataDivLeftHasTree">
     	
     	<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
			<tr class="operatorAction">
				<td>
				    <input type="hidden" id="selectdepname"/>
					<input type="button" style="margin-left:2px;width:50px;" value="刷新" onclick="refresh();"/>	
					<input type="button" style="margin-left:2px;width:100px;" value="原部门经办已申请" onclick="oldJbAsk();" />
					<input type="button" style="margin-left:2px;width:100px;" value="原部门经办已上报" onclick="oldJbReport();" />
					<input type="button" style="margin-left:2px;width:100px;" value="原部门领导已审核" onclick="oldLdAudit();" />
					<input type="button" style="margin-left:2px;width:100px;" value="原部门领导退回" onclick="oldLdBack();" />
					<input type="button" style="margin-left:2px;width:100px;" value="原部门领导已转交" onclick="oldLdPass(this);" />
					<input type="button" style="margin-left:2px;width:100px;" value="新部门领导已审核" onclick="newLDAudit();" />
					<input type="button" style="margin-left:2px;width:100px;" value="新部门领导退回" onclick="newLDBack();" />
					<input type="button" style="margin-left:2px;width:100px;" value="新部门领导已下传" onclick="newLDDownload();" />
					<input type="button" style="margin-left:2px;width:50px;" value="分配" onclick="newJBallot();" />
					<input type="button" style="margin-left:2px;width:50px;" value="导出" onclick="exportTable();" />
	                
			        
					查询条件：根据&nbsp;&nbsp;<select style="width: 94px;"  id="condition" onblur="chose();"> 
		  					<option selected="selected" value="zclb">资产类别</option>
		  					<option value="zczt">资产状态</option>
		  				</select>
		  				<input style="margin-left:10px;width: 150px" type="text" id="conditionValue" />
		  				<select style="display:none;width: 150px" class="qryTxt" id="acstatusValue">
	  						<option value="860" selected="selected">外调-原部门经办已申请</option>
							<option value="861">外调-原部门经办已上报</option>
							<option value="862">外调-原部门领导已审核</option>
							<option value="863">外调-原部门领导已转交</option>
							<option value="864">外调-新部门领导已审核</option>
							<option value="865">外调-新部门领导已下传</option>
	  					</select>
		       	        <input type="button" style="margin-left:1px;" value="查询" onclick="queryAssetCard()"/>
		
				</td>
			</tr> <!-- 功能性操作行  -->
			<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader" onclick="check(this)">
					  			<!-- 数据表头 -->
						  <td width="3%"><input id="checkAll" type="checkbox" name="check" value="checkbox" /></td> 
					      <td width="6%">资产卡片编号</td>	
						  <td width="6%">资产名称</td>
						  <td width="6%">所在部门</td>
						  <td width="6%">是否部门公用</td>
						  <td width="6%">使用人</td>
						  <td width="6%">操作人</td>
						  <td width="6%">操作角色</td>
						  <td width="8%">当前资产主状态</td>
						  <td width="6%">资产明细状态</td>
						  <td width="6%">处理结果</td>
						  <td width="6%">处理意见</td>
						  <td width="6%">处理时间</td>
						  <td width="6%">原使用部门</td>
						  <td width="6%">现使用部门</td>
						  <td width="5%">原使用人</td>
						  <td width="5%">现使用人</td>			  
						 
						</tr>
							<s:property value="pagination."/>	          
								<!-- 数据 -->
						<s:iterator var="ac" value="pagination.dataList">
						<tr class="dataRow" id="<s:property value='#ac.acid'/>" ondblclick="updateAssetCard('<s:property value="#ac.acid" />')" onclick="check(this)">
						  <td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid'/>" id="selectItem" /></td>
						  <td><s:property value="#ac.acid.substring(0,9)" /></td>
						  <td><s:property value="#ac.acname"/></td>
						  <td id="getdepnametocheck"> 
						     <s:property value="#ac.depname"/>
						  </td>
						 
						  <td>
						     <s:if test='#ac.ispublic=="Y"'>是</s:if>
						     <s:else>否</s:else>
						  </td>
						  <td><s:property value="#ac.acuser"/></td>
						  <td></td>
						  <td></td>
						  <td>
						    <s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						             <s:property value="desc.substring(0,3)"/>  
						       </s:if>
						   </s:iterator>
						  </td>
						  <td>
						      <s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						             <s:property value="desc.substring(4)"/>  
						       </s:if>
						     </s:iterator>
						  </td>
						  <td></td>
						  <td></td>
						  <td></td>
						  <td><s:property value="#ac.category.catname"/></td>
						  <td></td>
						  <td></td>
						  <td></td>
						</tr>
						</s:iterator>
     				</table>
     			</td>
     		</tr>	
			<tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>
     	</table>
    </div>
</div>
		<!-- 外调--原部门已申请 -->
		<form action="oldJbAsk.action" method="post"
			id="hiddengoodsform">
			<input type="hidden" id="hiddengoodsacid" name="idArray" />
			<input type="hidden" id="FN" name="FN"
				value="<s:property value='FN' />" />
		</form>
		<!-- 外调--原部门经办已上报 -->
		<form action="oldJbReport.action" method="post"
			id="hiddenallotform">
			<input type="hidden" id="hiddenallotacid" name="idArray" />
			<input type="hidden" id="result" name="result" />
			<input type="hidden" id="FN" name="FN"
				value="<s:property value='FN' />" />
		</form>
		<!--外调--原部门领导已审核-->
	<form action="oldLdAudit.action" method="post"
		id="hiddenfpform">
		<input type="hidden" id="hiddenfpacid" name="idArray" />
		<input type="hidden" id="oldLdAuditResult" name="result" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
			<!--外调--原部门领导退回资产-->
	<form action="oldLdBack.action" method="post"
		id="hiddenbackform">
		<input type="hidden" id="hiddenbackacid" name="idArray" />
		<input type="hidden" id="oldLdBackResult" name="result" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
		
			<!--外调--原部门领导已转交资产-->
	<form action="oldLdPass.action" method="post"
		id="hiddenpassform">
		<input type="hidden" id="hiddenpassacid" name="idArray" />
		<input type="hidden" id="depid" name="depid" />
		<input type="hidden" id="depname" name="depPassname" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	      <!--外调--新部门领导已审核资产-->
	<form action="newLDAudit.action" method="post"
		id="hiddenauditform">
		<input type="hidden" id="hiddenauditacid" name="idArray" />
		<input type="hidden" id="newLDAuditResult" name="result" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	<!--外调--新部门领导退回资产-->
	<form action="newLDBack.action" method="post"
		id="hiddennewbackform">
		<input type="hidden" id="hiddennewbackacid" name="idArray" />
		<input type="hidden" id="newLDBackResult" name="result" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	<!--外调--新部门领导已下传资产-->
	<form action="newLDDownload.action" method="post"
		id="hiddennewloadform">
		<input type="hidden" id="hiddennewloadacid" name="idArray" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	<!-- 外调--新部门经办进行物资的分配 -->
		<form action="newJBExternalallot.action" method="post"
		id="hiddennewfpform">
		<input type="hidden" id="hiddennewfpacid" name="idArray" />
		<input type="hidden" id="user" name="newuser" />
		<input type="hidden" id="FN" name="FN"
			value="<s:property value='FN' />" />
	</form>
	</body>
</html>
</html>
